
const { defineComponent } = Vue;

var trade = defineComponent({
    props:['trade',"index"] ,
    created(){
        this.producerList=app.producerList
        console.log("000000000000",app.producerList,this.producerList)
    },data(){return {
    }},methods:{
        getShop:function (shopId){
            for(var i = 0; i < app.shopList?.length;i++){
                if(shopId == app.shopList[i].id) return app.shopList[i];
            }
            return null;
        },getProducer:function (code,shop){
              var producerList = app.producerList;
              if(shop && shop.producerList) producerList=shop.producerList;
              for(var i = 0; i < producerList?.length;i++){
                  if(code == producerList[i].produceCode) return producerList[i];
              }
              return null;
          }
    },template:`<tr class="trade" :title="trade.subject">
        <td>{{index+1}}
        <input type="hidden" :value="shop=getShop(trade.shopId)" />
        </td>
        <td>{{trade.id}}</td>
        <td>{{trade.outTradeNo}}</td>
        <td>{{shop?.name}}</td>
        <td>{{trade.orderAt}}</td>
        <td>-</td>
         <td>{{trade.status}}</td>
        </tr>
        <tr class="cardgroup" v-if="trade.groupList" v-for="(g,gi) in trade.groupList">
        <td>{{gi+1}}</td>
        <td>{{g.id}}</td>
        <td colspan="2">{{g.classifier.texture}} {{g.classifier.lamination}}</td>
        <td>{{getProducer(g.produceType)?.name}}
            <label v-for="o in shop?.producerList">
                <span  clavss="btn btn-warning btn-sm" v-if="o.produceCode != g.produceType">转{{o.name}}<span>
            </label>
        </td>
        <td></td>
        <td>{{g.status}}</td>
        </tr>
        `
})

function loadShopData( ){
    axios.post('/shop/list', {}).then(function (response) {
        console.log("trade   app .data",app.$data.shopList)
        trade.$data.shoplist2 = response.data.data;
        console.log('/shop/list2222',trade.$data.shoplist2)
    }).catch(function (error) {
        console.log("error",error);
    });
}
export default trade;
